<%@ page pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        let user1 = {
            id:         100,
            name:       "Alan",
            birthDate:  "2000-01-01"
        };

        let json2_string = '{"id":"10000","name":"Tome","birthDate":"2020-12-12"}';

        // js转换json
        let json1_string = JSON.stringify(user1);
        // json 转 js
        let user2 = JSON.parse(json2_string);
        writePage(json1_string);
        
        writePage(user2);

        function writePage(str){
            document.write("<p>"+str+"</p>");
        };

    </script>
</head>
<body>
    
</body>
</html>